using System.Collections.Generic;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;

namespace GorillaEngine.Core.Engine {
    public class ContentLoader {
        private readonly ContentManager _contentManager;
        private readonly Dictionary<string, Texture2D> _contentDictionary;

        public ContentLoader(ContentManager contentManager) {
            _contentManager = contentManager;
            _contentDictionary = new Dictionary<string, Texture2D>();
        }

        public virtual Texture2D Get(string name) {
            if (!_contentDictionary.ContainsKey(name)) {
                var content = _contentManager.Load<Texture2D>(name);
                _contentDictionary.Add(name, content);
            }

            return _contentDictionary[name];
        }
    }
}